package MyAtomicInteger;

import java.util.concurrent.atomic.AtomicInteger;

public class MyAtomicInteger {
    public static void main(String[] args) throws InterruptedException {

        //AtomicInteger count = new AtomicInteger(0);
        int count = 0;
        for (int i = 0; i < 100; i++) {
            Thread thread = new Thread(()->{
                //++count
                //count.incrementAndGet();

                //++count
                //count.getAndIncrement();

                //count += delta
                for (int j = 0; j < 500; j++) {
                    //count++;
                }
            });
            thread.start();
        }

        //确保以上线程都执行完毕
        Thread.sleep(10000);
        //System.out.println(count.get());
    }
}
